<form class="layui-form layui-form-pane" method="post" action="" enctype="multipart/form-data" >
    @csrf
    <div class="layui-form-item">
        <label class="layui-form-label">问题</label>
        <div class="layui-input-inline" style="width:30%;">
            <input type="type" name="question" value='' required lay-verify="required" placeholder='请输入问题' autocomplete="off" class="layui-input" >
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">答案</label>

        <div class="layui-input-block">
            <textarea id="demo" style="display: none;" name="content"></textarea>
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <input type='hidden' name='id' value="{{$id}}">
    <input type="hidden" name="page" value="{{$request->page}}">
    <input type="hidden" name="keywords" value="{{$request->keywords}}">
    <input type="hidden" name="label" value="{{$request->label}}">
    <input type="hidden" name="types" value="{{$request->type}}">
    <input type="hidden" name="brand" value="{{$request->brand}}">
    <input type="hidden" name="state" value="{{$request->state}}">
    <input type="hidden" name="sell" value="{{$request->sell}}">
    <input type="hidden" name="month" value="{{$request->month}}">
    <input type="hidden" name="title" value="{{$request->title}}">
    <input type="hidden" name="sort" value="{{$request->sort}}">

</form>
<script>
    layui.use('layedit', function(){
        var layedit = layui.layedit,$ = layui.jquery;
        var index = layedit.build('demo'); //建立编辑器
    });
    //Demo
    layui.use(['layedit','form'], function(){
        var layedit = layui.layedit,$ = layui.jquery;
        var indexs = layedit.build('demo'); //建立编辑器
        var form = layui.form;

        //监听提交
        form.on('submit(formDemo)', function(data){
            layer.confirm('确认执行此操作？', {icon: 3, title:'提示'}, function(index){
                var page = $("input[name=page]").val();
                var keywords = $("input[name=keywords]").val();
                var label = $("input[name=label]").val();
                var types = $("input[name=types]").val();
                var brand = $("input[name=brand]").val();
                var state = $("input[name=state]").val();
                var sell = $("input[name=sell]").val();
                var month = $("input[name=month]").val();
                var title = $("input[name=title]").val();
                var sort = $("input[name=sort]").val();

                data.field.answer = layedit.getContent(indexs);
                {{--ajax("{{url('admin/shop/insert_q')}}",data.field,function(data){--}}
                ajax("{{url('admin/shop/source_insert_qanda')}}",data.field,function(data){
                    layer.close();
                    layer.closeAll();
                    layer.msg(data.msg);
                    if(data.code == 1){
                        location.href = location.href;
                        {{--location.href = '/admin/shop/source?id='+ {{$id}}+'&types='+3+'&page='+page+'&keywords='+keywords+'&label='+label+'&type='+types+'&brand='+brand+'&state='+state+'&sell='+sell+'&month='+month+'&title='+title+'&sort='+sort;--}}
                    }
                });
            });
            return false;
        });
    });
</script>
